Persist OAuth project scope - #216
Open
masnwilliams wants to merge 7 commits into
Open
Conversation
hiroTamada
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
kernel authtests
go test ./...go vet ./...go build ./...dependency
Pairs with kernel/kernel-mcp-server#138. The fields are optional, so this remains compatible with the currently deployed OAuth server.
Note
Medium Risk
Changes OAuth token handling and stored credential shape; behavior is backward compatible for legacy tokens but affects how scope is enforced for all OAuth sessions after login or refresh.
Overview
Adds organization-wide vs project-scoped OAuth to the CLI by persisting
access_scopeandproject_idon stored credentials.During login, the callback may carry scope in OAuth
state; after code exchange, token response fields override state fororg_id,access_scope, andproject_id. Missing scope defaults to organization-wide; org-wide tokens clearproject_id. The same fields are updated on refresh, with legacy tokens without scope fields treated as organization-wide.kernel authprints whether the session is organization-wide or locked to a project ID. README documents choosing scope at login and that project-scoped tokens cannot use--projectto switch projects.Tests cover authoritative scope from token exchange, refresh preserving project scope, and legacy refresh behavior.
Reviewed by Cursor Bugbot for commit c9eb41d. Bugbot is set up for automated code reviews on this repo. Configure here.